import coin.strategy.executor.common.parse_config as common_parse_config


class ExecutorConfigAdjuster(object):
  def __init__(self, config):
    self.set_config(config)
    self.hard_close = False

  @property
  def config(self):
    return self._config

  # adjustable configs
  @property
  def lot_size(self):
    return self._lot_size

  @property
  def min_pos(self):
    return self._min_pos

  @property
  def max_pos(self):
    return self._max_pos

  @property
  def pos_range(self):
    return self._config.max_pos - self._config.min_pos

  @property
  def reserve(self):
    return (self._config.min_pos + self._config.max_pos) / 2

  @property
  def close_only(self):
    return self._close_only

  def set_config(self, config):
    common_parse_config.check_pos_config(config)
    self._config = config
    self._lot_size = self._config.lot_size
    self._min_pos = self._config.min_pos
    self._max_pos = self._config.max_pos
    self._close_only = False

  def set_close_only(self, mode):
    self._close_only = mode
